qx.Class.define("lastfmbackup.Language", {
  
  statics : {
    
    _stringFormat : function()
    {
      var value = this;
      for(var i = 0; i < arguments.length; i++)
      {
        value = value.split('{' + i + '}').join(String(arguments[i]));
      }
    
      return value;
    },
    
    _objectDict : function(list)
    {
      var result = {};
      list.forEach(function(item)
      {
        result[item[0]] = item[1];
      });
      return result;
    },
    
    _objectItems : function(dict)
    {
      return Object.keys(dict).map(function(key)
      {
        return [key, dict[key]];
      });
    },
    
    _objectValues : function(object)
    {
      return Object.keys(object).map(function(key) 
      {
        return object[key];
      });
    }, 
    
    _objectMerge : function(target, varargs) 
    {
      for(var i = 1, l = arguments.length; i < l; i++) 
      {
        qx.lang.Object.mergeWith(target, arguments[i]);
      }

      return target;
    },
    
    _arrayRange : function(start, stop, step)
    {
      if(stop === undefined)
      {
        stop  = start;
        start = 0;
      }
      if(step === undefined)
      {
        step = 1;
      }
      if((step > 0 && start >= stop) || (step < 0 && start <= stop))
      {
        return [];
      }
      
      var result = [];
      for(var i = start; step > 0 ? i < stop : i > stop; i += step)
      {
        result.push(i);
      }
      
      return result;
    },

    _functionLambda : function(returns)
    {
      return function()
      {
        return returns;
      };
    }
    
  },
  
  defer : function(statics)
  {
    String.prototype.format = statics._stringFormat;
    
    Object.dict   = statics._objectDict;
    Object.items  = statics._objectItems;
    Object.values = statics._objectValues;
    Object.merge  = statics._objectMerge;
    
    Array.range = statics._arrayRange;
    
    Function.lambda = statics._functionLambda;
  }
  
});